const chooseWarehouse = {
  data() {
    return {
      entityWarehouseList: [], // 入库实体仓库列表
      virtualWarehouseList: [] // 入库虚拟仓库列表
    }
  },
  created() {
    const vm = this
    vm.getEntityWarehouseList() // 获取实体仓库列表
  },
  methods: {
    // 获取实体仓库列表
    getEntityWarehouseList() {
      const vm = this
      const params = {
        page: 1,
        limit: 100000000,
        type: 1, // 1-实体仓 2-虚拟仓 3-残品仓 4-FBA仓
        is_active: 1
      }
      vm.$http.get('/warehouse', { params }).then((res) => {
        vm.entityWarehouseList = res.data
      })
    },
    // 获取实体仓下面的虚拟仓库列表
    getVirtualWarehouseList(callback) {
      const vm = this
      const params = {
        page: 1,
        limit: 100000000,
        type: 2, // 1-实体仓 2-虚拟仓 3-残品仓 4-FBA仓
        parent_id: vm.formFieldsData.entity_warehouse_id,
        is_active: 1
      }
      vm.$http.get('/warehouse', { params }).then((res) => {
        vm.virtualWarehouseList = res.data
        if (typeof callback === 'function') {
          callback()
        }
      })
    }
  }
}
export default chooseWarehouse
